package o;

import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.BitmapFactory;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import com.huawei.appgallery.splashscreen.impl.cache.ImageCacheBean;

public class cyw {
    private static cyw ˊ;
    private static final Object ˋ = new Object();

    public static cyw ॱ() {
        cyw o_cyw;
        synchronized (ˋ) {
            if (ˊ == null) {
                ˊ = new cyw();
            }
            o_cyw = ˊ;
        }
        return o_cyw;
    }

    public Object ˏ(@NonNull ImageCacheBean imageCacheBean) {
        if (ॱ(imageCacheBean)) {
            if (ˎ(imageCacheBean)) {
                return ˊ(imageCacheBean);
            }
            return null;
        } else if (imageCacheBean.ˎ() >= System.currentTimeMillis()) {
            return null;
        } else {
            cys.ॱ(imageCacheBean.ᐝ());
            cys.ॱ(imageCacheBean.ʼ());
            cyq.ˋ.ˋ("FileValidationManager", "The event is over.");
            return null;
        }
    }

    private boolean ॱ(@NonNull ImageCacheBean imageCacheBean) {
        long currentTimeMillis = System.currentTimeMillis();
        return imageCacheBean.ˋ() <= currentTimeMillis && imageCacheBean.ˎ() > currentTimeMillis;
    }

    private boolean ˎ(@NonNull ImageCacheBean imageCacheBean) {
        long ˎ = czh.ˎ(imageCacheBean);
        if (ˎ <= 0) {
            return true;
        }
        long ʻ = czh.ʻ(imageCacheBean);
        int ʽ = czh.ʽ(imageCacheBean);
        if (ʻ <= 0 || ʽ <= 0 || System.currentTimeMillis() - ˎ >= ʻ) {
            return true;
        }
        int ʼ = czh.ʼ(imageCacheBean);
        if (!cyr.ˏॱ().ˎ() && ʼ >= ʽ) {
            cyq.ˋ.ˋ("FileValidationManager", "show times over,times: " + ʼ + ",unitNum: " + ʽ);
            return false;
        } else if (!cyr.ˏॱ().ˎ() || ʼ <= ʽ) {
            return true;
        } else {
            cyq.ˋ.ˋ("FileValidationManager", "show times over,times: " + ʼ + ",unitNum: " + ʽ);
            return false;
        }
    }

    private Object ˊ(@NonNull ImageCacheBean imageCacheBean) {
        Configuration configuration;
        Resources resources = cyn.ॱ() != null ? cyn.ॱ().getResources() : null;
        if (resources != null) {
            configuration = resources.getConfiguration();
        } else {
            configuration = null;
        }
        if (configuration == null) {
            return null;
        }
        String ˊ;
        String ˏ;
        if (2 == configuration.orientation) {
            ˊ = czh.ˊ(imageCacheBean);
            ˏ = czh.ˏ(imageCacheBean);
            if (imageCacheBean.ˊ() != 0 && (TextUtils.isEmpty(ˊ) || TextUtils.isEmpty(ˏ))) {
                ˊ = czh.ˋ(imageCacheBean);
                ˏ = czh.ॱ(imageCacheBean);
            }
        } else {
            ˊ = czh.ˋ(imageCacheBean);
            ˏ = czh.ॱ(imageCacheBean);
        }
        if (!cys.ˏ(ˊ, ˏ)) {
            ˊ = null;
        } else if (imageCacheBean.ˊ() == 0) {
            try {
                ˊ = BitmapFactory.decodeFile(ˊ);
            } catch (OutOfMemoryError e) {
                cyq.ˋ.ˊ("FileValidationManager", "getImageFile() OutOfMemoryError");
                ˊ = null;
            }
        }
        return ˊ;
    }
}
